#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;
const int mod = 998244353;

int a[N],n,f[N],lst[N];
bool vis[N];

int upd(int x) { return x + (x >> 31 & mod); }

struct BIT {
	int arr[N];
	void add(int x,int y) { for(;x <= n;x += x & -x) arr[x] = upd(arr[x] + y - mod); }
	int query(int x) { int res = 0; for(;x;x -= x & -x) res = upd(res + arr[x] - mod); return res; }
} T ;

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 1;i <= n;i++) a[i] = in;
	for(int i = 1;i <= n;i++) {
		f[i] = lst[a[i]] ? upd(T.query(i - 1) - T.query(lst[a[i]] - 1)) : upd(T.query(i - 1) + 1 - mod);
		T.add(i,f[i]); if(lst[a[i]]) T.add(lst[a[i]],upd(-f[lst[a[i]]])); lst[a[i]] = i;
	}
	printf("%d\n",T.query(n));
	return 0;
}
